package org.ala.distributed_transaction_commons.communication.participant;

import org.ala.distributed_transaction_commons.communication.AbstractAction;
import org.ala.distributed_transaction_commons.communication.Message.MessageContent;
import org.ala.distributed_transaction_commons.logs.LoggerFactory;
import org.slf4j.Logger;


/**
 * 参与者的action实现
 * 
 * @author 骆毅(ala)
 * @date 2024年2月19日
 */
public abstract class AbstractParticipantAction extends AbstractAction {

	
	static Logger log = LoggerFactory.getLogger("distributed_transaction/participant", "action");
	

	@Override
	public void execute(MessageContent mc) {
		log.info("[" + this.getClass().getSimpleName() + " execute] 收到消息，通知等待的线程 type:" + mc.getMsgType() + " biz:" + mc.getBiz() + " txId:" + mc.getTxId());
		
		//	取事务id
		String txId = mc.getTxId();
		
		//	直接通知等待的线程即可，线程自己会取redis取状态
		txId = txId.intern();
		synchronized (txId) {
			txId.notifyAll();
		}
	}

}
